<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link href="Public/Home/css/order2(1).css" type="text/css" rel="stylesheet"  />
		<script type="text/javascript" src="Public/Home/js/jquery-1.9.1.min.js"></script>
		<style type="text/css">
			.boxTwo{width:946px;height:30px;margin:0px auto 0px;border:1px solid #EEE;line-height:30px;background:#F5F5F5;}
			.boxOne{width:946px;background:#FFF;height:30px;line-height:30px;margin:5px auto;}
			.boxOne:hover{background:#F5F5F5;}
			.boxOne a{float:right;padding-right:20px;color:#005EAC;display:none;}
			.boxOne:hover a{display:block;}
			.Five{width:946px;margin:5px auto;padding:1px 0px;}
			.addBtn{width:80px;height:20px;background:#C00;line-height:20px;text-align:center;color:#FFF;cursor:pointer;}
			#redBorder{border:1px solid #C00;}
			#addrBox{position:relative;}
			#closeBtn{position:absolute;width:24px;height:24px;border-radius:5px;right:10px;top:10px;background:#F5F5F5;text-align:center;line-height:24px;cursor:pointer;}
			#closeBtn:hover{background:#CCC;}
		</style>
		<script type="text/javascript">
			$(function(){
				//alert(2);
				//判断是否有收货人地址，如果没有，则显示表单
				var num = $('.nameBox').val();
				if(num == null){
					$('.addrBox').css({"display":"block"});
				}
				//不用一个一个抓，用form包含起来，用提交事件一次抓取所有的值
				//这样效率更快，工作中不会让你一个一个的抓，那样时间不够
				//有更好的方法就用更好的方法
				//alert(1)都不好使是因为异步写错了，然后注释不起作用，所以alert(1)不执行
				$('#formBox1').submit(function(){
					//抓取form表单的所有内容，不用挨个抓取
					var formData = $(this).serialize();
					//alert(formData);
					//发送异步
					$.ajax({
						type:"post",
						url:"{{U('Order/addAddress')}}",
						data:formData,
						dataType:'json',
						success:function(phpData){
							//var str = '<tr class="msg-tr"><td>'+phpData.nickname+'</td><td>'+phpData.content+'</td><td>操作</td></tr>';	
							//var str = '<span>'+phpData.addrname+'</span>';
							//$('#eee').html(str);							
							var str = '<div class="boxTwo">收货人:'+phpData.addrname+'&nbsp;&nbsp;&nbsp;收货地址:'+phpData.address+'&nbsp;&nbsp;&nbsp;手机号码:'+phpData.phone_mob+'</div>';
							//追加到html内
							$('.Five').append(str);
							$('.addrBox').css({"display":"none"});																																			
						}
					});
					//阻止表单提交
					return false;
				})
				$('.addBtn').click(function(){
					$('.addrBox').css({"display":"block"}); 
				})
				//关闭
				$('#closeBtn').click(function(){
					$('.addrBox').css({"display":"none"}); 
				})
			})
		</script>
	</head>
	<body>
		<!--headerBegin-->
		<!--header-->
		<div id="topnav">
			<div class="wbox clearfix">
				<!--left-->
				<ul class="topside">
					<li id="topNavHover" class="vphone">
						<b></b>
						<a href="#" target="_blank">手机国美</a>
						<div class="vphone-down">
							<a href="#" target="_blank"></a>
							<em class="i-angle"><i></i></em>
						</div>
					</li>
					<li><a href="#" target="_blank" title="国之美">国之美</a></li>
					<li><a href="#" target="_blank" title="多边黄金">多边黄金</a></li>
				</ul>
				<!--right-->
				<ul class="topmenu clearfix">
					<li class="login-top">
						<span class="gwelcome">国美在线欢迎您！</span>
						<!--只要$_SESSION里面有name就算登录-->
                		<?php if(isset($_SESSION['username'])): ?>
                			<font color="#C00">您好，<?php echo $_SESSION['username'] ?></font>
                			<a class="glogin" href="{{U('Login/out')}}">退出</a>
                		<?php else: ?>
                			<a class="glogin" href="{{U('Login/index')}}">登录</a>   
                		<?php endif ?>
						<a class="gsign" href="#">注册</a>
					</li>
					<li class="linespace"></li>
					<li class="g-myoder"><a  href="#">我的订单</a></li>
					<li><a  href="#">我的国美</a></li>
					<li class="linespace"></li>
					<li class="g-myoder"><a  href="#">在线客服</a></li>
					<li><a  href="#">服务中心</a></li>
					<li class="g-myoder"><a  href="#">企业服务</a></li>
					<li><a  href="#">国美社区</a></li>
					<li class="g-myoder"><a  href="#">商家入驻</a></li>
				</ul>
			</div>
		</div>
		<!--header_ok-->
		<!--headerEnd-->
		
		
		<!--topEnd-->
		<!--logo-->
		<div class="nMain">
			<!--顶部logo-->
			<div class="nTop clearfix">
				<h1 class="logo"><a href="#" title="国美在线" target="_blank"><img src="Public/Home/images/skin/gomelogo.png"></a></h1>
				<ul class="steps">
					<li class="last"><b>3</b><em class="f">成功提交订单</em></li>
					<li class="cur"><b>2</b><span class="going"></span><em class="f">填写核对订单信息</em></li>
					<li class="first ok"><b>1</b><span class="going1" style="background-color: #C00;"></span><em class="f">我的购物车</em></li>
				</ul>
			</div>
			<!--顶部logo_end-->
			<div class="nMyCartName"><b class="name fontYaHei">填写核对订单信息</b></div>
			
			<!--收货人信息-->
			<div class="addBtn">新增收货地址</div>		
			{{if value="!empty($addrData)"}}  <!--用!empty()判断为空 可以-->
				{{foreach from="$addrData" key="$k" value="$v"}}
				<div class="xxBox">
					<input type="hidden" class="nameBox" value="{{$k}}"  />				
					<div class="boxOne" <?php if($v['is_default'] == 1): ?> id="redBorder" <?php endif ?> >
						{{$v['addrname']}} &nbsp;&nbsp;&nbsp; {{$v['region']}} {{$v['address']}} &nbsp;&nbsp;&nbsp; 电话:{{$v['phone_mob']}}				
						<a href="javascript:if(confirm('确认删除吗？')) location.href='{{U('Order/del',array('addrid'=>$v['addrid']))}}';">删除</a>
						<a href="javascript:;" class="editBtn" addrid="{{$v['addrid']}}" addrname="{{$v['addrname']}}" region="{{$v['region']}}" address="{{$v['address']}}" phone_mob="{{$v['phone_mob']}}" phone_tel="{{$v['phone_tel']}}" email="{{$v['email']}}" user_uid="{{$v['user_uid']}}">编辑</a>
						<a href="{{U('Order/is_default',array('addrid'=>$v['addrid']))}}">设为默认地址</a>
					</div>	
				</div>				
				{{endforeach}}		
			{{endif}}
			<div class="Five"></div>
			<form id="formBox1">
				<div class="addrBox" style="display:none;">						
					<span id="eee"></span> <span id="closeBtn">X</span>
					<!--当前用户id-->
					<input type="hidden" value="{{$_SESSION['uid']}}" id="userID" name="userID" />
					<h2>收货人地址</h2>
					<div class="inputBox">
						*收货人:
						<input type="text" class="txtBox" id="addrname" value="" name="addrname" />
					</div>
					<div class="inputBox">
						*所在地区:
						<!--城市联动-->
			                <script type="text/javascript" src="Public/Home/js/area.js"></script>
							<script type="text/javascript">
								$(function(){
									//初始化方法
									area.init('area');
									//修改的时候默认被选中效果
									area.selected('黑龙江','哈尔滨','道里区');
								})
							</script>
			                <select name="" id="area1"></select>
							<select name="" id="area2"></select>
							<select name="" id="area3"></select>  
						<!--城市联动_ok-->
					</div>
					<div class="inputBox">
						*详细地址:
						<input type="text"  class="txtBox" style="width:300px;" value="" id="address" name="address"/>
					</div>
					<div class="inputBox">
						*手机号码:
						<input type="text"  class="txtBox" value="" id="phone_mob" name="phone_mob"/>
						或 固定电话:
						<input type="text"  class="txtBox" value="" id="phone_tel" name="phone_tel"/>
					</div>
					<div class="inputBox">
						*邮箱:
						<input type="text"  class="txtBox" value="" id="email" name="email"/>
					</div>			
					<input type="submit" class="addrBtn" value="保存收货人地址">
					<input type="reset" class="addrBtn" value="重置">
				</div>
			</form>		
			<!--收货人信息_ok-->
			
			<!--支付及配送方法-->
			<!--支付及配送方法都是用异步添加的-->
			<div class="payment">
				<h2>支付及配送方式<a href="#">[修改]</a></h2>
				<div class="paytitle">支付方式</div>
				<div class="paytxt">
					<input type="radio" checked="checked" name="payment"/> 货到付款				
				</div>
				<div class="paytxt">
					<input type="radio" name="payment"  /> 在线支付
				</div>
				<div class="paytxt">
					<input type="radio" name="payment"  /> 信用卡分期付款
				</div>
				<div class="paytitle">配送方式</div>
				<div class="paytxt">
					送货时间:
					<input type="radio" checked="checked" name="deliveryway"/> 只工作日送货
					<i></i>
					<input type="radio" name="deliveryway" /> 只双休日、假日送货
					<i></i>
					<input type="radio" name="deliveryway" /> 工作日、双休日与假日均可送货
				</div>
				<div class="payBtn">保存支付及配送方式</div>
			</div>
			<!--支付及配送方法_ok-->
			
			<!--商品清单-->
			<div class="payment">
				<div class="paytitle">商品清单</div>
				<table cellpadding="0" cellspacing="0" width="100%">
					<tr bgcolor="#F5F5F5" height="30px">
						<th width="12%" align="center"></th>
						<th>商品</th>
						<th width="12%">单价(元)</th>
						<th width="12%">促销</th>
						<th width="12%">数量</th>
						<th width="12%">库存</th>
					</tr>
					<!--商品清单和购物车取得都是SESSION里的东西-->	    			        
			        {{foreach from="$_SESSION['cart']['goods']" key="$k" value="$v"}}
					<tr>
						<td align="center"><img src="{{$v['options']['pic']}}" width="50" height="50" /></td>
						<td>{{$v['name']}} | {{$v['options']['size']}} | {{$v['options']['color']}}</td>
						<td align="center">{{$v['price']}}</td>
						<td>已直降￥400.00 {{  intval($v['price'])*intval($v['num'])   }}</td>
						<td align="center">{{$v['num']}}</td>
						<td align="center">有货</td>
					</tr>
					{{endforeach}}
					
				</table>
				<div style="width:946px;height:60px;line-height:20px;text-align:right;">
					<font color="#C00"><?php echo Cart::getTotalNums(); ?></font>件商品  商品总计: ￥<?php echo Cart::getTotalPrice(); ?>.00<br />
							运费: +￥0.00						
				</div>
				<div style="width:946px;height:60px;line-height:20px;text-align:right;background:#F5F5F5;border:2px solid #E65500;">
						:0种 0件,￥<?php echo Cart::getTotalPrice(); ?>.00					
				</div>
				<div style="width:946px;height:30px;line-height:30px;text-align:right;">
						<font color="#C00"><b>应付总额:￥<?php echo Cart::getTotalPrice(); ?>.00</b></font><input type="button" value="提交订单" style="padding:3px 5px;background:#C00;color:#FFF;outline:none;border:none;cursor:pointer;"/>				
				</div>
			</div>
			<!--商品清单_ok-->
			
		</div>
		
		
		
		
		
		
		
		
		
		<!--编辑收货人地址 弹窗-->
		<!--  登录弹出层  -->
		<div id="login-dialogBox"></div>
		<style type="text/css">
			#NOT{color:#C00;}
			/*  弹出层  */
			#yonghu,#mima{width:300px;height:30px;margin:10px auto 0px;color:#6D6D6D;font-size:14px;}
			#txt,#pwd,#pwd2{width:200px;height:24px;outline:none;border-radius:4px;border:1px solid #9D9D9D;}
			
			#anniuBox{width:120px;height:36px;margin:20px auto;}
			#regAnniu,#loginAnniu{width:120px;height:36px;background:#87B1BD;color:#FFF;line-height:36px;text-align:center;font-size:14px;font-weight:700;border:none;outline:none;margin:0px auto;border-radius:4px;}
			/* 弹出层_ok */
			.redWord{text-decoration: underline;color:#C00;background:#F68567;padding:2px 5px;}
		</style>
		<link rel="stylesheet" type="text/css" href="Public/Home/css/jquery.dialogbox.css" />
		<script type="text/javascript" src="Public/Home/js/jquery.dialogBox.js"></script>
		<script type="text/javascript">
			$(function(){
				//初始化方法
				area.init('area');
				//修改的时候默认被选中效果
				area.selected('黑龙江','哈尔滨','道里区');
			})
		</script>
		<script type="text/javascript">
			$(function(){
				$('.editBtn').each(function(){
					var jq_this = $(this);
					//var d = jq_this.attr('id');
					//alert(d);
					//var jq_this = $(this); //jquery里指当前抓取的元素
					//var js_this = this;   //原生js 里 指当前对象 可以在这个上面添加属性
					jq_this.click(function(){
						//因为没有经过{{U('')}},所以没有经过后台
						alert(jq_this.attr('addrid'));
						
						$('#login-dialogBox').dialogBox({
								width: 500,
								height: 300,
								title: '编辑收货人信息',
								hasClose: true,
								content: '<form id="formBox22" action="{{U('Order/edit')}}" method="post"><div class="addrBox"><span id="eee"></span><input type="hidden" value="'+jq_this.attr('addrid')+'" id="userID" name="addrid" /><input type="hidden" value="'+jq_this.attr('user_uid')+'" id="userID" name="userID" /><h2>收货人地址</h2><div class="inputBox">*收货人:<input type="text" class="txtBox" id="addrname" value="'+jq_this.attr('addrname')+'" name="addrname" /></div><div class="inputBox">*所在地区:<select name="" id="area1"></select><select name="" id="area2"></select><select name="" id="area3"></select></div><div class="inputBox">*详细地址:<input type="text"  class="txtBox" style="width:300px;" value="'+jq_this.attr('address')+'" id="address" name="address"/></div><div class="inputBox">*手机号码:<input type="text"  class="txtBox" value="'+jq_this.attr('phone_mob')+'" id="phone_mob" name="phone_mob"/>或 固定电话:<input type="text"  class="txtBox" value="'+jq_this.attr('phone_tel')+'" id="phone_tel" name="phone_tel"/></div><div class="inputBox">*邮箱:<input type="text"  class="txtBox" value="'+jq_this.attr('email')+'" id="email" name="email"/></div><input type="submit" class="addrBtn" value="保存收货人地址"><input type="reset" class="addrBtn" value="重置"></div></form> '
						});
						
						
					})
				})				
			})
		</script>
	</body>
</html>
